package 力扣日常刷题.木22一月.第14天0123;

/**
 * @author 帅小伙
 * @date 2022/1/23
 * @description
 */
public class Demo54动态规划只有两个按键的键盘 {


    public int minSteps(int n) {
        int[] dp = new int[n+1];
        for (int i = 2; i <= n ; i++) {
            dp[i] = Integer.MAX_VALUE;
            for (int j = 1; j*j <= i ; j++) {
                if(i%j == 0){
                    dp[i] = Math.min(dp[i],dp[j]+i/j);
                    dp[i] = Math.min(dp[i],dp[i/j]+j);
                }
            }
        }
        return dp[n];
    }
}
